import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:youfangtong_module/native/native.dart';
import 'package:youfangtong_module/widgets/my_colors.dart';

/// 我的页面
class MinePage extends StatefulWidget {

  const MinePage({super.key});

  @override
  State<StatefulWidget> createState() {
    return _MinePageState();
  }

}

class _MinePageState extends State<MinePage> {

  @override
  Widget build(BuildContext context) {
    return Container(
      color: MyColors.color_F5F5F5,
      padding: const EdgeInsets.symmetric(horizontal: 20),
      child: Column(
        children: [
          _getNameAvatar(),
          _getRolePhone(),
          _getCollection(),
          _getMessageVersion(),
          _getLogout(),
          _recordNumber()
        ],
      ),
    );
  }

  /// 姓名,头像
  Widget _getNameAvatar() {
    return Container(
      margin: const EdgeInsets.fromLTRB(0,72,0,20),
      child: Row(
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Text(
                  "吴猛",
                style: TextStyle(
                  fontSize: 24,
                  color: MyColors.color_000000
                ),
              ),
              Container(
                margin: const EdgeInsets.only(left: 5),
                padding: const EdgeInsets.symmetric(vertical: 2,horizontal: 10),
                decoration: BoxDecoration(
                    color: MyColors.color_EBEDFA,
                  borderRadius: BorderRadius.circular(4)
                ),
                child: Text(
                  "拓维",
                  style: TextStyle(
                    fontSize: 10,
                    color: MyColors.color_1C234D
                  ),
                ),
              )
            ],
          ),
          Expanded(flex: 1, child: Container()),
          GestureDetector(
            onTap: () => {
              NativeChannel.nativeMethod("toHomePage")
            },
            child: const CircleAvatar(
              radius: 30,
              backgroundImage: AssetImage("assets/images/avatar.png"),
            ),
          )
        ],
      ),
    );
  }

  /// 切换角色,手机号
  Widget _getRolePhone() {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8)
      ),
      child: Column(
        children: [
          GestureDetector(
            onTap: () => {},
            child: Container(
              padding: const EdgeInsets.all(15),
              child: Row(
                children: [
                  Text(
                    "切换角色",
                    style: TextStyle(
                        fontSize: 14,
                        color: MyColors.color_3D3D3D
                    ),
                  ),
                  Expanded(flex: 1,child: Container()),
                  Text(
                    "拓维",
                    style: TextStyle(
                        fontSize: 14,
                        color: MyColors.color_C7C7C7
                    ),
                  ),
                  Container(
                    margin: const EdgeInsets.only(left: 10),
                    child: SvgPicture.asset("assets/images/right_arrow.svg", width: 5, height: 9),
                  )
                ],
              ),
            ),
          ),
          GestureDetector(
            onTap: () => {},
            child: Container(
              padding: const EdgeInsets.all(15),
              child: Row(
                children: [
                  Text(
                    "我的手机号",
                    style: TextStyle(
                        fontSize: 14,
                        color: MyColors.color_3D3D3D
                    ),
                  ),
                  Expanded(flex: 1,child: Container()),
                  Text(
                    "18549806225",
                    style: TextStyle(
                        fontSize: 14,
                        color: MyColors.color_C7C7C7
                    ),
                  ),
                  Container(
                    margin: const EdgeInsets.only(left: 10),
                    child: SvgPicture.asset("assets/images/right_arrow.svg", width: 5, height: 9),
                  )
                ],
              ),
            ),
          )
        ],
      ),
    );
  }

  /// 收藏
  Widget _getCollection() {
    return GestureDetector(
      onTap: () => {},
      child: Container(
        margin: const EdgeInsets.only(top: 10),
        padding: const EdgeInsets.all(15),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(8)
        ),
        child: Row(
          children: [
            Text(
              "我的收藏",
              style: TextStyle(
                  fontSize: 14,
                  color: MyColors.color_3D3D3D
              ),
            ),
            Expanded(flex: 1,child: Container()),
            SvgPicture.asset("assets/images/right_arrow.svg", width: 5, height: 9)
          ],
        ),
      ),
    );
  }

  /// 消息通知，意见反馈，隐私权政策，版本号
  Widget _getMessageVersion() {
    return Container(
      margin: const EdgeInsets.only(top: 10),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8)
      ),
      child: Column(
        children: [
          GestureDetector(
            onTap: () => {},
            child: Container(
              padding: const EdgeInsets.all(15),
              child: Row(
                children: [
                  Text(
                    "消息通知",
                    style: TextStyle(
                      fontSize: 14,
                      color: MyColors.color_3D3D3D
                    ),
                  ),
                  Expanded(flex: 1, child: Container()),
                  Text(
                      "开启",
                    style: TextStyle(
                      fontSize: 14,
                      color: MyColors.color_C7C7C7
                    ),
                  ),
                  Container(
                    margin: const EdgeInsets.only(left: 10),
                    child: SvgPicture.asset("assets/images/right_arrow.svg",width: 5,height: 9),
                  )
                ],
              ),
            ),
          ),
          GestureDetector(
            onTap: () => {},
            child: Container(
              padding: const EdgeInsets.all(15),
              child: Row(
                children: [
                  Text(
                    "意见反馈",
                    style: TextStyle(
                        fontSize: 14,
                        color: MyColors.color_3D3D3D
                    ),
                  ),
                  Expanded(flex: 1, child: Container()),
                  Container(
                    margin: const EdgeInsets.only(left: 10),
                    child: SvgPicture.asset("assets/images/right_arrow.svg",width: 5,height: 9),
                  )
                ],
              ),
            ),
          ),
          GestureDetector(
            onTap: () => {},
            child: Container(
              padding: const EdgeInsets.all(15),
              child: Row(
                children: [
                  Text(
                    "隐私权政策",
                    style: TextStyle(
                        fontSize: 14,
                        color: MyColors.color_3D3D3D
                    ),
                  ),
                  Expanded(flex: 1, child: Container()),
                  Container(
                    margin: const EdgeInsets.only(left: 10),
                    child: SvgPicture.asset("assets/images/right_arrow.svg",width: 5,height: 9),
                  )
                ],
              ),
            ),
          ),
          GestureDetector(
            onTap: () => {},
            child: Container(
              padding: const EdgeInsets.all(15),
              child: Row(
                children: [
                  Text(
                    "版本号",
                    style: TextStyle(
                        fontSize: 14,
                        color: MyColors.color_3D3D3D
                    ),
                  ),
                  Expanded(flex: 1, child: Container()),
                  Text(
                    "2.40.2",
                    style: TextStyle(
                        fontSize: 14,
                        color: MyColors.color_C7C7C7
                    ),
                  )
                ],
              ),
            ),
          )
        ],
      ),
    );
  }

  /// 退出登录
  Widget _getLogout() {
    return GestureDetector(
      child: Container(
          margin: const EdgeInsets.only(top: 10),
          padding: const EdgeInsets.all(15),
          alignment: Alignment.center,
          decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(8)
          ),
          child: Text(
            "退出登录",
            style: TextStyle(
                fontSize: 14,
                fontWeight: FontWeight.bold,
                color: MyColors.color_FC5151
            ),
          )
      )
    );
  }

  /// 备案号
  Widget _recordNumber() {
    return GestureDetector(
      onTap: () => {},
      child: Container(
        margin: const EdgeInsets.only(top: 20),
        child: const Text(
          "ICP备案号: 沪ICP备17013391号-2A",
          style: TextStyle(
              color: Colors.grey,
              fontSize: 10
          ),
        ),
      ),
    );
  }

}